/*
 * @Author: gitee_com_zb
 * @Date: 2024-11-14 17:46:52
 * @LastEditors: gitee_com_zb
 * @LastEditTime: 2024-11-14 17:47:01
 * @FilePath: /lzb/GiteeCode/algorithm/优选算法38.替换所有的问号(easy).cpp
 * @Description: 题目链接 https://leetcode.cn/problems/replace-all-s-to-avoid-consecutive-repeating-characters
 */
class Solution {
public:
    string modifyString(string s) {
        int n = s.size();
        for(int i = 0; i < n; i++) {
            if(s[i] == '?') 
                for(char ch = 'a'; ch <= 'z'; ch++){
                    if((i == 0 ||ch != s[i - 1]) && (i == n-1 || ch != s[i + 1])) 
                    {s[i] = ch; break;}
                }
        }
        return s;
    }
};